package handlers

import (
	"earth/models"

	"github.com/gin-gonic/gin"
)

type UserHandler struct {
	BaseHandler
}

func (u *UserHandler) GetAllUsers(c *gin.Context) {
	users := models.GetUsers()
	c.JSON(200, users)
}

func (u *UserHandler) GetUserByID(c *gin.Context) {

	id, err := u.getStringParam(c, "id")
	if err != nil {
		c.JSON(400, "could not parse id")
		return
	}
	user, err := models.GetUserByID(id)
	if err != nil {
		c.JSON(404, "Not Found")
		return
	}

	c.JSON(200, user)
}
